<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>企业微信信息化平台</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body>

<script th:src="@{/layui/layui.js}"></script>

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.6.0.js"></script>
<div class="search">
    <ul class="layui-nav" lay-filter="">

        <div class="layui-form-item">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label">人员名字</label>
                    <div class="layui-input-inline" style="width: 130px;">
                        <input type="text" name="engineer_name" placeholder="输入名字或部门" class="layui-input">
                    </div>

                    <label class="layui-form-label">群组名字</label>
                    <div class="layui-input-inline" style="width: 130px;">
                        <input type="text" name="group_name" placeholder="输入群名" class="layui-input">
                    </div>
                    <label class="layui-form-label">消息类型</label>
                    <div class="layui-input-inline" style="width: 130px;">
                        <input type="radio" name="type" value="2" title="全部">
                        <input type="radio" name="type" value="problem" title="问题">
                        <input type="radio" name="type" value="message" title="信息" checked>
                    </div>
                    <label class="layui-form-label">是否处理</label>
                    <div class="layui-input-inline" style="width: 130px;">
                        <input type="radio" name="status" value="2" title="全部">
                        <input type="radio" name="status" value="1" title="已经处理">
                        <input type="radio" name="status" value="0" title="未处理" checked>


                    </div>


                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>


                    <!--                <div class="layui-form-mid">-</div>-->
                    <!--                <div class="layui-input-inline" style="width: 100px;">-->
                    <!--                    <input type="text" name="price_max" placeholder="￥" autocomplete="off" class="layui-input">-->
                    <!--                </div>-->
                </div>
            </form>
            <!--            <div class="layui-inline">-->
            <!--                <label class="layui-form-label">时间</label>-->
            <!--                <div class="layui-input-inline" style="width: 100px;">-->
            <!--                    <input type="password" name="" autocomplete="off" class="layui-input">-->
            <!--                </div>-->
            <!--            </div>-->

        </div>

        <!--        <div class="layui-inline">-->
        <!--            <li class="layui-nav-item">-->
        <!--                <button class="layui-btn" id="demo1">-->
        <!--                    人员选择-->
        <!--                    <i class="layui-icon layui-icon-down layui-font-12"></i>-->
        <!--                </button>-->
        <!--            </li>-->

        <!--            <li class="layui-nav" lay-filter="">-->
        <!--                <input type="text" name="title"  required lay-verify="required" placeholder=""-->
        <!--                       autocomplete="off"-->
        <!--                       class="layui-input" id="workerName">-->
        <!--            </li>-->
        <!--        </div>-->
    </ul>

</div>
<table class="layui-table">
    <colgroup>
        <col width="150">
        <col width="200">
        <col>
    </colgroup>
    <thead>
    <tr id="question_list_head">

    </tr>
    </thead>
    <tbody id="question_list">

    </tbody>
</table>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>面板嵌套</legend>
</fieldset>
<div class="layui-collapse" lay-accordion="" lay-filter="test1">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">文豪</h2>
        <div class="layui-colla-content layui-show">

            <div class="layui-collapse" lay-accordion="">
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">唐代</h2>
                    <div class="layui-colla-content layui-show">

                        <div class="layui-collapse" lay-accordion="">
                            <div class="layui-colla-item">
                                <h2 class="layui-colla-title">杜甫</h2>
                                <div class="layui-colla-content layui-show">
                                    伟大的诗人
                                </div>
                            </div>
                            <div class="layui-colla-item">
                                <h2 class="layui-colla-title">李白</h2>
                                <div class="layui-colla-content">
                                    <p>据说是韩国人</p>
                                </div>
                            </div>
                            <div class="layui-colla-item">
                                <h2 class="layui-colla-title">王勃</h2>
                                <div class="layui-colla-content">
                                    <p>千古绝唱《滕王阁序》</p>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">宋代</h2>
                    <div class="layui-colla-content">
                        <p>比如苏轼、李清照</p>
                    </div>
                </div>
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">当代</h2>
                    <div class="layui-colla-content">
                        <p>比如贤心</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">科学家</h2>
        <div class="layui-colla-content">
            <p>伟大的科学家</p>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">艺术家</h2>
        <div class="layui-colla-content">
            <p>浑身散发着艺术细胞</p>
        </div>
    </div>
</div>

<br>


<script>

    layui.use('element', function () {

        let element = layui.element;
        //监听折叠
        element.on('collapse(test)', function (data) {
            layer.msg('展开状态：' + data.show);
        });
    });


    let question_list_head = document.getElementById("question_list_head")
    let question_list = document.getElementById("question_list")

    // {"engineer_name":"","group_name":"","type":"problem","status":"all"}

    layui.use('form', function () {
        var form = layui.form;
        form.on('select(formDemo)', function (data) {
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
        });

        form.on('submit(formDemo)', function (data) {
            question_list.innerHTML = ""
            // layer.msg(JSON.stringify(data.field));
            let choose = data.field.type
            console.log(choose)
            $.ajax({
                url: "/msg_search"
                , data: {
                    data: JSON.stringify(data.field)
                }
                , type: "get"
                , dataType: "json"
                // , contentType: "application/json;charset=utf-8"
                , success: function (data) {


                    let row = "";
                    let head = "";
                    // head = "<tr>"
                    // // for (let key in data[0]) {
                    // //     head = head + "<th>" + key + "</th>"
                    // // }
                    // head = head + "</tr>"
                    // console.log(data[1])

                    question_list_head = head
                    // console.log(data.length + "data.length")
                    for (let i = 0; i < data.length; i++) {
                        console.log(data)

                        for (let key in data[i]) {
                            if (data[i][key] != null) {

                                row = row + "<td width='80'>" + data[i][key] + "</td>"
                                // console.log(key + "" + data[i][key])
                            }
                        }

                        row = "<tr>" + row + "</tr>"

                        // console.log(row + "end")
                    }
                    question_list.innerHTML = question_list.innerHTML + row
                    // console.log(data)
                    //      $("#question_list").html(obj.title);
                    // console.log(data)
                    // layer.msg(data);
                }
            })


            return false;
        });
    });

    // ajax()

    function ajax() {
        $.ajax({
            url: "/msg_all_need_reply"
            // , data: data.field
            , type: "get"
            , dataType: "json"
            // , contentType: "application/json;charset=utf-8"
            , success: function (data) {
                if (data.status === "200") {
                    layer.open({
                        title: '提示'
                        , content: "注册成功"
                    });
                } else if (data.status === "301") {
                    layer.open({
                        title: '提示'
                        , content: "用户名已存在"
                    });
                    return false;
                } else {
                    layer.open({
                        title: '提示'
                        , content: "请求错误，请联系管理员"
                    });
                    console.log(data)
                    return false;
                }
            }
        })
    }


    layui.use('dropdown', function () {
        const dropdown = layui.dropdown;
        dropdown.render({
            elem: '#demo1'
            , data: [{
                title: 'menu item 1'
            }, {
                title: 'menu item 2'
                , id: 101
            }]
            , id: 'demo1'
            //菜单被点击的事件
            , click: function (obj) {
                console.log(obj);
                $("#demo1").html(obj.title);

                layer.msg('回调返回的参数已显示再控制台');
            }
        });
    });

    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;

        //…
    });
</script>


</body>
</html>